home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-02 | 2.2 KB | 88 lines | [TEXT/????] |
- NB. miscellaneous utilities
- NB.
- NB. bx indices of 1's in boolean
- NB. deb delete extra blanks
- NB. diff differences
- NB. expand expand numeric argument
- NB. fi fix rank 1
- NB. flatten flatten display to matrix
- NB. ifempty return 1 if empty
- NB. jl justify left
- NB. jr justify right
- NB. lindex linear indices - indexing utility
- NB. nubcount nub + count
- NB. pathname split DOS name into path;name
- NB. ruler ruler
- NB. show show explicit definition
- NB. sort sort
-
- t=. 'bx deb diff expand fi flatten'
- t=. t,' ifempty jl jr lindex nubcount'
- t=. t,' pathname ruler show sort'
- SCRIPTNAMES=: t
-
- bx=: # i. @ #
- deb=: '(b+.1|.b></\b=.y.~:'' '')#y.' :0
- diff=: 2&(-~/\)
- expand=: (* +/\) @ [ { 0&,@]
- fi=: '0'&"."1
- flatten=: 1 1&}. @ (_1 _1&}.)@ ": @ <
- ifempty=: 0&=&:>
- jl=: (|.~ +/@(*./\)@(' '&=))"1
- jr=: (|.~ -@(+/)@(*./\.)@(' '&=))"1
- c1=. +/"1@=
- c2=. \:@c1 f.
- nubcount=: (c2 f. { ~.) ;"0 (c2 { c1) f.
- pathname=: '(b#y.);(-.b=.+./\.y.=''\'')#y.' :0
- sort=: /:~
-
- NB. lindex
- NB. e.g. 2 lindex 5 3$'a'
- NB. = 6 7 8 (indices of row 2)
- lindex=: [ { i.@$@]
-
- NB. ruler
- NB. displays a ruler
- NB. e.g. ruler 75
- NB. 1 ruler 30
- ruler=: 0 : 0
- 0 ruler y.
- :
- j=. >. 0.2*len=. y.
- $.=. >x.{L0;L1
-
- L0) r=. len #"1 ,. 193 32 194{a.
- i=. }. 5*i.j
- r=. (197{a.) (,(0,+:len)+/0,i) } r
- r=. ('0',3 ": i) (len,,len+i-/2 1 0) } r
- r [ $.=. i.0
-
- L1) r=. len # ,: 197 32 32 197{a.
- i=. 0,}. 5*i.j
- r=. (197{a.) (,0 3 +/ i*4) } r
- r=. (,2 ": 100|i) (,(i*4) +/ 1 2) } r
- )
-
- NB. show
- NB. e.g. show 'ruler'
- show=: 0 : 0
- 1 1 show y.
- :
- NB. show explicit definition of verb
- NB. x.= (1=line nos), (1=frame)
- x.=. 2{.x.
- $.=. (y.-:>y.)}.$.
- ,.(<x.)$:&.>y. [ $.=. ''
- 'ajc'=. ,.&.>5!:2<y.
- y.=. ':',~y.-.' '
- $.=. ,>(0{x.){L0;$.
- r=. (#a)>.#c
- b=. ' '={."1 r=. ":,.i.r
- r=. '[',"1 b|."0 1 r,"1'] '
- a=. ((#a){.r),"1 a
- c=. ((#c){.r),"1 c
- L0)$.=. {.(-. 1{x.)}.$.
- ,.y.;a;c
- y.,a,(-.0 e. $c)#(,'≡≡≡'),c
- )
-